home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 34 / Amiga Format CD34 (1998-11-20)(Future Publishing)(GB)[!][Christmas issue].iso / -seriously_amiga- / programming / basic / blitzc2p / c2p / c2pgenericcls.ascii < prev    next >
Text File  |  1998-10-01  |  9KB  |  511 lines

  1. WBStartup
  2. NoCli
  3.  
  4. ; CLEARSCREEN version. Additional code by Paul West.
  5.  
  6. ; Non-clearscreen results:
  7.  
  8. ; 040/25 results:
  9.  
  10. ; 320x200 @42fps DoublePAL or 44fps PAL
  11. ; 320x256 @31fps DoublePAL or 34fps PAL
  12. ; 320x240 @33.7fps DoublePAL or 36.5fps PAL
  13.  
  14. #c2pBPLX=320
  15. #c2pBPLY=256
  16. #c2pBPLSIZE=(#c2pBPLX*#c2pBPLY)/8
  17.  
  18. #scrwidth=#c2pBPLX
  19. #scrheight=#c2pBPLY
  20. #screensize=#scrwidth*#scrheight
  21.  
  22. #clearscreento=$00000000
  23.  
  24. ; 060 friendly version
  25. ;       modulo  max res fscreen compu
  26. ; c2p1x1_8_c5     no  320x256?  no  030
  27.  
  28. Statement c2pGenericInit{A.l,B.l}
  29.  
  30.   ;A.l=d0=Width.w
  31.   ;B.l=d1=Height.w
  32.  
  33. ; d0.w  chunkyx [chunky-pixels]
  34. ; d1.w  chunkyy [chunky-pixels]
  35. ; d3.w  scroffsy [screen-pixels]
  36.  
  37.   MOVEQ.l #0,d3 ; Y offset
  38.  
  39. c2p1x1_8_c5_init
  40.   LEA c2p_data(pc),a0
  41.   ANDI.l  #$ffff,d0
  42.   MULU.w  d0,d3
  43.   LSR.l #3,d3
  44.   MOVE.l  d3,c2p_scroffs-c2p_data(a0)
  45.   MULU.w  d0,d1
  46.   MOVE.l  d1,c2p_pixels-c2p_data(a0)
  47. AsmExit
  48. End Statement
  49.  
  50. Statement c2pGeneric{A.l,B.l}
  51.  
  52.   MOVE.l  d0,a0 ; Chunky
  53.   MOVE.l  d1,a1 ; Planar
  54.  
  55. ; a0  c2pscreen
  56. ; a1  bitplanes
  57.  
  58. c2p1x1_8_c5
  59.   MOVEM.l a3-a6,-(a7)
  60.  
  61.   LEA c2p_data(pc),a2
  62.  
  63.   MOVE.l  #$33333333,d5
  64.   MOVE.l  #$55555555,a6
  65.  
  66.   ADD.w #c2pBPLSIZE,a1
  67.   ADD.l c2p_scroffs-c2p_data(a2),a1
  68.  
  69.   MOVE.l  c2p_pixels-c2p_data(a2),a2
  70.   ADD.l a0,a2
  71.   CMP.l a0,a2
  72.   BEQ _none
  73.  
  74.   MOVEM.l a0-a1,-(a7)
  75.  
  76.   MOVE.l  (a0),d0
  77.   MOVE.l  #clearscreento,(a0)+
  78.   MOVE.l  (a0),d2
  79.   MOVE.l  #clearscreento,(a0)+
  80.   MOVE.l  (a0),d1
  81.   MOVE.l  #clearscreento,(a0)+
  82.   MOVE.l  (a0),d3
  83.   MOVE.l  #clearscreento,(a0)+
  84.  
  85.   MOVE.l  #$0f0f0f0f,d4   ; Merge 4x1, part 1
  86.   AND.l d4,d0
  87.   AND.l d4,d1
  88.   AND.l d4,d2
  89.   AND.l d4,d3
  90.   LSL.l #4,d0
  91.   LSL.l #4,d1
  92.   OR.l  d2,d0
  93.   OR.l  d3,d1
  94.  
  95.   MOVE.l  (a0),d2
  96.   MOVE.l  #clearscreento,(a0)+
  97.   MOVE.l  (a0),d6
  98.   MOVE.l  #clearscreento,(a0)+
  99.   MOVE.l  (a0),d3
  100.   MOVE.l  #clearscreento,(a0)+
  101.   MOVE.l  (a0),d7
  102.   MOVE.l  #clearscreento,(a0)+
  103.  
  104.   AND.l d4,d2     ; Merge 4x1, part 2
  105.   AND.l d4,d6
  106.   AND.l d4,d3
  107.   AND.l d4,d7
  108.   LSL.l #4,d2
  109.   LSL.l #4,d3
  110.   OR.l  d6,d2
  111.   OR.l  d7,d3
  112.  
  113.   MOVE.w  d2,d6     ; Swap 16x2
  114.   MOVE.w  d3,d7
  115.   MOVE.w  d0,d2
  116.   MOVE.w  d1,d3
  117.   SWAP  d2
  118.   SWAP  d3
  119.   MOVE.w  d2,d0
  120.   MOVE.w  d3,d1
  121.   MOVE.w  d6,d2
  122.   MOVE.w  d7,d3
  123.  
  124.   MOVE.l  d2,d6     ; Swap 2x2
  125.   MOVE.l  d3,d7
  126.   LSR.l #2,d6
  127.   LSR.l #2,d7
  128.   EOR.l d0,d6
  129.   EOR.l d1,d7
  130.   AND.l d5,d6
  131.   AND.l d5,d7
  132.   EOR.l d6,d0
  133.   EOR.l d7,d1
  134.   LSL.l #2,d6
  135.   LSL.l #2,d7
  136.   EOR.l d6,d2
  137.   EOR.l d7,d3
  138.  
  139.   MOVE.l  #$00ff00ff,d4
  140.   MOVE.l  d1,d6     ; Swap 8x1
  141.   MOVE.l  d3,d7
  142.   LSR.l #8,d6
  143.   LSR.l #8,d7
  144.   EOR.l d0,d6
  145.   EOR.l d2,d7
  146.   BRA _start1
  147. _x1
  148.   MOVE.l  (a0),d0
  149.   MOVE.l  #clearscreento,(a0)+
  150.   MOVE.l  (a0),d2
  151.   MOVE.l  #clearscreento,(a0)+
  152.   MOVE.l  (a0),d1
  153.   MOVE.l  #clearscreento,(a0)+
  154.   MOVE.l  (a0),d3
  155.   MOVE.l  #clearscreento,(a0)+
  156.   MOVE.l  d7,-c2pBPLSIZE(a1)
  157.  
  158.   MOVE.l  #$0f0f0f0f,d4   ; Merge 4x1, part 1
  159.   AND.l d4,d0
  160.   AND.l d4,d1
  161.   AND.l d4,d2
  162.   AND.l d4,d3
  163.   LSL.l #4,d0
  164.   LSL.l #4,d1
  165.   OR.l  d2,d0
  166.   OR.l  d3,d1
  167.  
  168.   MOVE.l  (a0),d2
  169.   MOVE.l  #clearscreento,(a0)+
  170.   MOVE.l  (a0),d6
  171.   MOVE.l  #clearscreento,(a0)+
  172.   MOVE.l  (a0),d3
  173.   MOVE.l  #clearscreento,(a0)+
  174.   MOVE.l  (a0),d7
  175.   MOVE.l  #clearscreento,(a0)+
  176.   MOVE.l  a3,c2pBPLSIZE(a1)
  177.  
  178.   AND.l d4,d2     ; Merge 4x1, part 2
  179.   AND.l d4,d6
  180.   AND.l d4,d3
  181.   AND.l d4,d7
  182.   LSL.l #4,d2
  183.   LSL.l #4,d3
  184.   OR.l  d6,d2
  185.   OR.l  d7,d3
  186.  
  187.   MOVE.w  d2,d6     ; Swap 16x2
  188.   MOVE.w  d3,d7
  189.   MOVE.w  d0,d2
  190.   MOVE.w  d1,d3
  191.   SWAP  d2
  192.   SWAP  d3
  193.   MOVE.w  d2,d0
  194.   MOVE.w  d3,d1
  195.   MOVE.w  d6,d2
  196.   MOVE.w  d7,d3
  197.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  198.  
  199.   MOVE.l  d2,d6     ; Swap 2x2
  200.   MOVE.l  d3,d7
  201.   LSR.l #2,d6
  202.   LSR.l #2,d7
  203.   EOR.l d0,d6
  204.   EOR.l d1,d7
  205.   AND.l d5,d6
  206.   AND.l d5,d7
  207.   EOR.l d6,d0
  208.   EOR.l d7,d1
  209.   LSL.l #2,d6
  210.   LSL.l #2,d7
  211.   EOR.l d6,d2
  212.   EOR.l d7,d3
  213.  
  214.   MOVE.l  #$00ff00ff,d4
  215.   MOVE.l  d1,d6     ; Swap 8x1
  216.   MOVE.l  d3,d7
  217.   LSR.l #8,d6
  218.   LSR.l #8,d7
  219.   EOR.l d0,d6
  220.   EOR.l d2,d7
  221.   MOVE.l  a5,(a1)+
  222. _start1
  223.   AND.l d4,d6
  224.   AND.l d4,d7
  225.   EOR.l d6,d0
  226.   EOR.l d7,d2
  227.   LSL.l #8,d6
  228.   LSL.l #8,d7
  229.   EOR.l d6,d1
  230.   EOR.l d7,d3
  231.  
  232.   MOVE.l  a6,d4
  233.   MOVE.l  d1,d6     ; Swap 1x1
  234.   MOVE.l  d3,d7
  235.   LSR.l #1,d6
  236.   LSR.l #1,d7
  237.   EOR.l d0,d6
  238.   EOR.l d2,d7
  239.   AND.l d4,d6
  240.   AND.l d4,d7
  241.   EOR.l d6,d0
  242.   EOR.l d7,d2
  243.   ADD.l d6,d6
  244.   ADD.l d7,d7
  245.   EOR.l d1,d6
  246.   EOR.l d3,d7
  247.  
  248.   MOVE.l  d0,a4
  249.   MOVE.l  d2,a5
  250.   MOVE.l  d6,a3
  251.  
  252.   CMPA.l  a0,a2
  253.   BNE _x1
  254.   MOVE.l  d7,-c2pBPLSIZE(a1)
  255.   MOVE.l  a3,c2pBPLSIZE(a1)
  256.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  257.   MOVE.l  a5,(a1)+
  258.  
  259.   MOVEM.l (a7)+,a0-a1
  260.   ADD.l #c2pBPLSIZE*4,a1
  261.  
  262.   MOVE.l  (a0),d0
  263.   MOVE.l  #clearscreento,(a0)+
  264.   MOVE.l  (a0),d2
  265.   MOVE.l  #clearscreento,(a0)+
  266.   MOVE.l  (a0),d1
  267.   MOVE.l  #clearscreento,(a0)+
  268.   MOVE.l  (a0),d3
  269.   MOVE.l  #clearscreento,(a0)+
  270.  
  271.   MOVE.l  #$f0f0f0f0,d4   ; Merge 4x1, part 1
  272.   AND.l d4,d0
  273.   AND.l d4,d1
  274.   AND.l d4,d2
  275.   AND.l d4,d3
  276.   LSR.l #4,d2
  277.   LSR.l #4,d3
  278.   OR.l  d2,d0
  279.   OR.l  d3,d1
  280.  
  281.   MOVE.l  (a0),d2
  282.   MOVE.l  #clearscreento,(a0)+
  283.   MOVE.l  (a0),d6
  284.   MOVE.l  #clearscreento,(a0)+
  285.   MOVE.l  (a0),d3
  286.   MOVE.l  #clearscreento,(a0)+
  287.   MOVE.l  (a0),d7
  288.   MOVE.l  #clearscreento,(a0)+
  289.  
  290.   AND.l d4,d2     ; Merge 4x1, part 2
  291.   AND.l d4,d6
  292.   AND.l d4,d3
  293.   AND.l d4,d7
  294.   LSR.l #4,d6
  295.   LSR.l #4,d7
  296.   OR.l  d6,d2
  297.   OR.l  d7,d3
  298.  
  299.   MOVE.w  d2,d6     ; Swap 16x2
  300.   MOVE.w  d3,d7
  301.   MOVE.w  d0,d2
  302.   MOVE.w  d1,d3
  303.   SWAP  d2
  304.   SWAP  d3
  305.   MOVE.w  d2,d0
  306.   MOVE.w  d3,d1
  307.   MOVE.w  d6,d2
  308.   MOVE.w  d7,d3
  309.  
  310.   MOVE.l  d2,d6     ; Swap 2x2
  311.   MOVE.l  d3,d7
  312.   LSR.l #2,d6
  313.   LSR.l #2,d7
  314.   EOR.l d0,d6
  315.   EOR.l d1,d7
  316.   AND.l d5,d6
  317.   AND.l d5,d7
  318.   EOR.l d6,d0
  319.   EOR.l d7,d1
  320.   LSL.l #2,d6
  321.   LSL.l #2,d7
  322.   EOR.l d6,d2
  323.   EOR.l d7,d3
  324.  
  325.   MOVE.l  #$00ff00ff,d4
  326.   MOVE.l  d1,d6     ; Swap 8x1
  327.   MOVE.l  d3,d7
  328.   LSR.l #8,d6
  329.   LSR.l #8,d7
  330.   EOR.l d0,d6
  331.   EOR.l d2,d7
  332.   BRA _start2
  333. _x2
  334.   MOVE.l  (a0),d0
  335.   MOVE.l  #clearscreento,(a0)+
  336.   MOVE.l  (a0),d2
  337.   MOVE.l  #clearscreento,(a0)+
  338.   MOVE.l  (a0),d1
  339.   MOVE.l  #clearscreento,(a0)+
  340.   MOVE.l  (a0),d3
  341.   MOVE.l  #clearscreento,(a0)+
  342.   MOVE.l  d7,-c2pBPLSIZE(a1)
  343.  
  344.   MOVE.l  #$f0f0f0f0,d4   ; Merge 4x1, part 1
  345.   AND.l d4,d0
  346.   AND.l d4,d1
  347.   AND.l d4,d2
  348.   AND.l d4,d3
  349.   LSR.l #4,d2
  350.   LSR.l #4,d3
  351.   OR.l  d2,d0
  352.   OR.l  d3,d1
  353.  
  354.   MOVE.l  (a0),d2
  355.   MOVE.l  #clearscreento,(a0)+
  356.   MOVE.l  (a0),d6
  357.   MOVE.l  #clearscreento,(a0)+
  358.   MOVE.l  (a0),d3
  359.   MOVE.l  #clearscreento,(a0)+
  360.   MOVE.l  (a0),d7
  361.   MOVE.l  #clearscreento,(a0)+
  362.   MOVE.l  a3,c2pBPLSIZE(a1)
  363.  
  364.   AND.l d4,d2     ; Merge 4x1, part 2
  365.   AND.l d4,d6
  366.   AND.l d4,d3
  367.   AND.l d4,d7
  368.   LSR.l #4,d6
  369.   LSR.l #4,d7
  370.   OR.l  d6,d2
  371.   OR.l  d7,d3
  372.  
  373.   MOVE.w  d2,d6     ; Swap 16x2
  374.   MOVE.w  d3,d7
  375.   MOVE.w  d0,d2
  376.   MOVE.w  d1,d3
  377.   SWAP  d2
  378.   SWAP  d3
  379.   MOVE.w  d2,d0
  380.   MOVE.w  d3,d1
  381.   MOVE.w  d6,d2
  382.   MOVE.w  d7,d3
  383.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  384.  
  385.   MOVE.l  d2,d6     ; Swap 2x2
  386.   MOVE.l  d3,d7
  387.   LSR.l #2,d6
  388.   LSR.l #2,d7
  389.   EOR.l d0,d6
  390.   EOR.l d1,d7
  391.   AND.l d5,d6
  392.   AND.l d5,d7
  393.   EOR.l d6,d0
  394.   EOR.l d7,d1
  395.   LSL.l #2,d6
  396.   LSL.l #2,d7
  397.   EOR.l d6,d2
  398.   EOR.l d7,d3
  399.  
  400.   MOVE.l  #$00ff00ff,d4
  401.   MOVE.l  d1,d6     ; Swap 8x1
  402.   MOVE.l  d3,d7
  403.   LSR.l #8,d6
  404.   LSR.l #8,d7
  405.   EOR.l d0,d6
  406.   EOR.l d2,d7
  407.   MOVE.l  a5,(a1)+
  408. _start2
  409.   AND.l d4,d6
  410.   AND.l d4,d7
  411.   EOR.l d6,d0
  412.   EOR.l d7,d2
  413.   LSL.l #8,d6
  414.   LSL.l #8,d7
  415.   EOR.l d6,d1
  416.   EOR.l d7,d3
  417.  
  418.   MOVE.l  a6,d4
  419.   MOVE.l  d1,d6     ; Swap 1x1
  420.   MOVE.l  d3,d7
  421.   LSR.l #1,d6
  422.   LSR.l #1,d7
  423.   EOR.l d0,d6
  424.   EOR.l d2,d7
  425.   AND.l d4,d6
  426.   AND.l d4,d7
  427.   EOR.l d6,d0
  428.   EOR.l d7,d2
  429.   ADD.l d6,d6
  430.   ADD.l d7,d7
  431.   EOR.l d1,d6
  432.   EOR.l d3,d7
  433.  
  434.   MOVE.l  d0,a4
  435.   MOVE.l  d2,a5
  436.   MOVE.l  d6,a3
  437.  
  438.   CMPA.l  a0,a2
  439.   BNE _x2
  440.   MOVE.l  d7,-c2pBPLSIZE(a1)
  441.   MOVE.l  a3,c2pBPLSIZE(a1)
  442.   MOVE.l  a4,c2pBPLSIZE*2(a1)
  443.   MOVE.l  a5,(a1)+
  444.  
  445. _none
  446.   MOVEM.l (a7)+,a3-a6
  447.   AsmExit
  448.  
  449.   Even4
  450. c2p_data
  451. c2p_screen: Dc.l 0
  452. c2p_scroffs: Dc.l 0
  453. c2p_scroffs2: Dc.l 0
  454. c2p_c2pBPLSIZE: Dc.l 0
  455. c2p_pixels: Dc.l 0
  456.   Ds.l  16
  457. End Statement
  458.  
  459.  
  460.  
  461. .blitzprogram
  462. ; Setup
  463. InitBank 0,(#scrwidth*#scrheight)+1000,2|65536 ; Chipram planar buffer
  464. CludgeBitMap 0,#scrwidth,#scrheight,8,Bank(0)
  465. InitPalette 0,256
  466. For c=0 To 255
  467.   AGAPalRGB 0,c,Rnd(c),Rnd(c),Rnd(c)
  468. Next c
  469. AGAPalRGB 0,0,0,0,0
  470. Screen 0,0,0,#scrwidth,#scrheight,8,0,"c2p test",0,0,0
  471. Use Palette 0
  472. VWait 50
  473. baseaddress1.l=AllocMem(#scrwidth*#scrheight,$10000) ; Fastram chunky buffer
  474.  
  475. ; Put something into the chunky buffer so we can see it working
  476. GetReg a0,baseaddress1
  477. MOVE.l  #0,d0
  478. MOVE.l  #screensize-1,d1
  479. cloop
  480.   MOVE.b  d0,(a0)+
  481.   ADDQ.